<template>
  <el-container>
    <el-aside width="200px">
      <!--v-sidebar是侧导航-->
      <el-menu :default-active="cligoss" :router="true" unique-opened class="el-menu-vertical-demo">
        <template v-for="(item, itemsIndex) in dataList[0].children">
          <!-- 二级菜单 -->
          <el-submenu :index="String(itemsIndex)" :key="itemsIndex" v-if="item.children">
            <template slot="title">
              <i :class="item.iconName"></i>
              <span>{{ item.menuName }}</span>
            </template>
            <el-menu-item-group v-for="(childrenItem, childrenIndex) in item.children" :key="childrenIndex">
              <el-menu-item v-show="!childrenItem.handerShow" :index="String(childrenItem.indexPath)">
                <span class="span" :title="childrenItem.menuName">
                  <i :class="childrenItem.iconName"></i>
                  {{ childrenItem.menuName }}
                </span>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <!-- 一级菜单 -->
          <template v-else>
            <el-menu-item :index="String(item.indexPath)" :key="item.indexPath">
              <i :class="item.iconName"></i>
              <span slot="title" style="font-weight: 600">{{
                item.menuName
              }}</span>
            </el-menu-item>
          </template>
        </template>
      </el-menu>
    </el-aside>
    <el-main>
      <div style="overflow:'auto;">
        <transition name="move" mode="out-in">
          <!--这里的router-view用来渲染子页面-->
          <router-view></router-view>
        </transition>
      </div>
    </el-main>
  </el-container>
</template>
<script>
import { menuDatasSINGLE, menuDatasONLINE } from "@/assets/js/menudata";
//引入侧导航组件
export default {
  name: "asiders",
  data() {
    return {
      menuDatasSINGLE: menuDatasSINGLE,
      menuDatasONLINE: menuDatasONLINE,
      menuList: [],
      userType: window.sessionStorage.getItem("userName"),
      systemMode: window.systemMode,
      dataList: [],
      cligoss: "",
    };
  },
  created() {},
  mounted() {
    if (systemMode == "SINGLE") {
      this.menuList = this.menuDatasSINGLE[this.userType];
    } else {
      this.menuList = this.menuDatasONLINE[this.userType];
    }

    console.log(this.menuList, "menuList");
    this.menuList.forEach((item) => {
      if (item.indexPath == this.$route.path) {
        this.dataList.push(item);
      }
    });
    this.cligoss = this.dataList[0].children[0].indexPath;
    console.log(this.cligoss);
    this.clasoss(this.dataList[0].children[0].indexPath);
  },
  methods: {
    clasoss(index) {
      console.log(index);
      this.$router.push(index);
    },
  },
};
</script>
<style scoped>
</style>